#include <stdio.h>
void quickSort(int arr[], int left, int right);
int main() {
    int arr[] = {4, 3, 8, 2, 1, 7, 5, 6, 9, 0};
    quickSort(arr, 0, 9);  //10个数字下标就是0-9
    for (int i = 0; i < 10; ++i) {
        printf("%d ", arr[i]);
    }
}
void quickSort(int *arr, int left, int right) {  //arr是数组，left是起始下标，right是结束下标
    if (left >= right) return;
    int base = arr[left], arr_l = left, arr_r = right;
    while (arr_l < arr_r) {
        while (arr_l < arr_r && arr[arr_r] >= base) arr_r--;
        arr[arr_l] = arr[arr_r];
        while (arr_l < arr_r && arr[arr_l] <= base) arr_l++;
        arr[arr_r] = arr[arr_l];
    }
    arr[arr_r] = base;
    quickSort(arr, left, arr_r - 1);
    quickSort(arr, arr_r + 1, right);
}
